package com.wave.reader
{
	import flash.utils.ByteArray;
	import flash.utils.Endian;
	
	public class WaveReader
	{
		
		
		public var bytes:ByteArray;
		public var chunkId:String;
		public var chunkSize:int;
		public var chunkFormat:String;
		public var subchunk1Id:String;
		public var subchunk1Size;
		public var audioFormat;
		public var channels;
		public var sampleRate;
		public var bytesPersecond;
		public var blockAlign;
		public var bitsPerSample;
		public var dataChunkSignature:String;
		public var dataChunkLength;
		
		
		function WaveReader(){
			
		}
		
		public function read(bytes:ByteArray):void{
			this.bytes = bytes;
			bytes.endian = "littleEndian";
			chunkId = bytes.readMultiByte(4,"utf");
			chunkSize = bytes.readUnsignedInt();
			chunkFormat = bytes.readMultiByte(4,"utf");
			
			subchunk1Id = bytes.readMultiByte(4,"iso-8859-1");
			subchunk1Size = bytes.readInt();
			audioFormat = bytes.readShort();
			channels = bytes.readShort();
			sampleRate = bytes.readUnsignedInt();
			bytesPersecond = bytes.readUnsignedInt();
			blockAlign = bytes.readShort();
			bitsPerSample = bytes.readUnsignedShort();
			dataChunkSignature = bytes.readMultiByte(4,"iso-8859-1");
			dataChunkLength = bytes.readInt();
			
		}
	}
}
